{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "from keras.applications.inception_v3 import InceptionV3\n",
    "from keras.models import Sequential, load_model, Model\n",
    "from keras.layers import Input, Dropout, Flatten, Conv2D, MaxPooling2D, Dense, Activation, GlobalAveragePooling2D\n",
    "from keras.optimizers import SGD\n",
    "from keras.utils import np_utils\n",
    "from keras.preprocessing.image import ImageDataGenerator\n",
    "from keras.callbacks import TensorBoard\n",
    "import itertools"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# all images will be converted to this size\n",
    "ROWS = 256\n",
    "COLS = 256\n",
    "CHANNELS = 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Found 5994 images belonging to 200 classes.\n",
      "Found 5794 images belonging to 200 classes.\n"
     ]
    }
   ],
   "source": [
    "train_image_generator = ImageDataGenerator(horizontal_flip=True, rescale=1./255, rotation_range=45)\n",
    "test_image_generator = ImageDataGenerator(horizontal_flip=False, rescale=1./255, rotation_range=0)\n",
    "\n",
    "train_generator = train_image_generator.flow_from_directory('train', target_size=(ROWS, COLS), class_mode='categorical')\n",
    "test_generator = test_image_generator.flow_from_directory('test', target_size=(ROWS, COLS), class_mode='categorical')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# create the base pre-trained model\n",
    "base_model = InceptionV3(weights='imagenet', include_top=False)\n",
    "\n",
    "# add a global spatial average pooling layer\n",
    "x = base_model.output\n",
    "x = GlobalAveragePooling2D()(x)\n",
    "# add a fully-connected layer\n",
    "x = Dense(1024, activation='relu')(x)\n",
    "out_layer = Dense(200, activation='softmax')(x)\n",
    "\n",
    "# this is the model we will train\n",
    "model = Model(inputs=base_model.input, outputs=out_layer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "__________________________________________________________________________________________________\n",
      "Layer (type)                    Output Shape         Param #     Connected to                     \n",
      "==================================================================================================\n",
      "input_1 (InputLayer)            (None, None, None, 3 0                                            \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_1 (Conv2D)               (None, None, None, 3 864         input_1[0][0]                    \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_1 (BatchNor (None, None, None, 3 96          conv2d_1[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "activation_1 (Activation)       (None, None, None, 3 0           batch_normalization_1[0][0]      \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_2 (Conv2D)               (None, None, None, 3 9216        activation_1[0][0]               \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_2 (BatchNor (None, None, None, 3 96          conv2d_2[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "activation_2 (Activation)       (None, None, None, 3 0           batch_normalization_2[0][0]      \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_3 (Conv2D)               (None, None, None, 6 18432       activation_2[0][0]               \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_3 (BatchNor (None, None, None, 6 192         conv2d_3[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "activation_3 (Activation)       (None, None, None, 6 0           batch_normalization_3[0][0]      \n",
      "__________________________________________________________________________________________________\n",
      "max_pooling2d_1 (MaxPooling2D)  (None, None, None, 6 0           activation_3[0][0]               \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_4 (Conv2D)               (None, None, None, 8 5120        max_pooling2d_1[0][0]            \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_4 (BatchNor (None, None, None, 8 240         conv2d_4[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "activation_4 (Activation)       (None, None, None, 8 0           batch_normalization_4[0][0]      \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_5 (Conv2D)               (None, None, None, 1 138240      activation_4[0][0]               \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_5 (BatchNor (None, None, None, 1 576         conv2d_5[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "activation_5 (Activation)       (None, None, None, 1 0           batch_normalization_5[0][0]      \n",
      "__________________________________________________________________________________________________\n",
      "max_pooling2d_2 (MaxPooling2D)  (None, None, None, 1 0           activation_5[0][0]               \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_9 (Conv2D)               (None, None, None, 6 12288       max_pooling2d_2[0][0]            \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_9 (BatchNor (None, None, None, 6 192         conv2d_9[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "activation_9 (Activation)       (None, None, None, 6 0           batch_normalization_9[0][0]      \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_7 (Conv2D)               (None, None, None, 4 9216        max_pooling2d_2[0][0]            \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_10 (Conv2D)              (None, None, None, 9 55296       activation_9[0][0]               \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_7 (BatchNor (None, None, None, 4 144         conv2d_7[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_10 (BatchNo (None, None, None, 9 288         conv2d_10[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_7 (Activation)       (None, None, None, 4 0           batch_normalization_7[0][0]      \n",
      "__________________________________________________________________________________________________\n",
      "activation_10 (Activation)      (None, None, None, 9 0           batch_normalization_10[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "average_pooling2d_1 (AveragePoo (None, None, None, 1 0           max_pooling2d_2[0][0]            \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_6 (Conv2D)               (None, None, None, 6 12288       max_pooling2d_2[0][0]            \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_8 (Conv2D)               (None, None, None, 6 76800       activation_7[0][0]               \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_11 (Conv2D)              (None, None, None, 9 82944       activation_10[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_12 (Conv2D)              (None, None, None, 3 6144        average_pooling2d_1[0][0]        \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_6 (BatchNor (None, None, None, 6 192         conv2d_6[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_8 (BatchNor (None, None, None, 6 192         conv2d_8[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_11 (BatchNo (None, None, None, 9 288         conv2d_11[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_12 (BatchNo (None, None, None, 3 96          conv2d_12[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_6 (Activation)       (None, None, None, 6 0           batch_normalization_6[0][0]      \n",
      "__________________________________________________________________________________________________\n",
      "activation_8 (Activation)       (None, None, None, 6 0           batch_normalization_8[0][0]      \n",
      "__________________________________________________________________________________________________\n",
      "activation_11 (Activation)      (None, None, None, 9 0           batch_normalization_11[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_12 (Activation)      (None, None, None, 3 0           batch_normalization_12[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "mixed0 (Concatenate)            (None, None, None, 2 0           activation_6[0][0]               \n",
      "                                                                 activation_8[0][0]               \n",
      "                                                                 activation_11[0][0]              \n",
      "                                                                 activation_12[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_16 (Conv2D)              (None, None, None, 6 16384       mixed0[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_16 (BatchNo (None, None, None, 6 192         conv2d_16[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_16 (Activation)      (None, None, None, 6 0           batch_normalization_16[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_14 (Conv2D)              (None, None, None, 4 12288       mixed0[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_17 (Conv2D)              (None, None, None, 9 55296       activation_16[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_14 (BatchNo (None, None, None, 4 144         conv2d_14[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_17 (BatchNo (None, None, None, 9 288         conv2d_17[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_14 (Activation)      (None, None, None, 4 0           batch_normalization_14[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_17 (Activation)      (None, None, None, 9 0           batch_normalization_17[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "average_pooling2d_2 (AveragePoo (None, None, None, 2 0           mixed0[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_13 (Conv2D)              (None, None, None, 6 16384       mixed0[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_15 (Conv2D)              (None, None, None, 6 76800       activation_14[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_18 (Conv2D)              (None, None, None, 9 82944       activation_17[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_19 (Conv2D)              (None, None, None, 6 16384       average_pooling2d_2[0][0]        \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_13 (BatchNo (None, None, None, 6 192         conv2d_13[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_15 (BatchNo (None, None, None, 6 192         conv2d_15[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_18 (BatchNo (None, None, None, 9 288         conv2d_18[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_19 (BatchNo (None, None, None, 6 192         conv2d_19[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_13 (Activation)      (None, None, None, 6 0           batch_normalization_13[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_15 (Activation)      (None, None, None, 6 0           batch_normalization_15[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_18 (Activation)      (None, None, None, 9 0           batch_normalization_18[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_19 (Activation)      (None, None, None, 6 0           batch_normalization_19[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "mixed1 (Concatenate)            (None, None, None, 2 0           activation_13[0][0]              \n",
      "                                                                 activation_15[0][0]              \n",
      "                                                                 activation_18[0][0]              \n",
      "                                                                 activation_19[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_23 (Conv2D)              (None, None, None, 6 18432       mixed1[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_23 (BatchNo (None, None, None, 6 192         conv2d_23[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_23 (Activation)      (None, None, None, 6 0           batch_normalization_23[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_21 (Conv2D)              (None, None, None, 4 13824       mixed1[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_24 (Conv2D)              (None, None, None, 9 55296       activation_23[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_21 (BatchNo (None, None, None, 4 144         conv2d_21[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_24 (BatchNo (None, None, None, 9 288         conv2d_24[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_21 (Activation)      (None, None, None, 4 0           batch_normalization_21[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_24 (Activation)      (None, None, None, 9 0           batch_normalization_24[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "average_pooling2d_3 (AveragePoo (None, None, None, 2 0           mixed1[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_20 (Conv2D)              (None, None, None, 6 18432       mixed1[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_22 (Conv2D)              (None, None, None, 6 76800       activation_21[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_25 (Conv2D)              (None, None, None, 9 82944       activation_24[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_26 (Conv2D)              (None, None, None, 6 18432       average_pooling2d_3[0][0]        \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_20 (BatchNo (None, None, None, 6 192         conv2d_20[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_22 (BatchNo (None, None, None, 6 192         conv2d_22[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_25 (BatchNo (None, None, None, 9 288         conv2d_25[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_26 (BatchNo (None, None, None, 6 192         conv2d_26[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_20 (Activation)      (None, None, None, 6 0           batch_normalization_20[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_22 (Activation)      (None, None, None, 6 0           batch_normalization_22[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_25 (Activation)      (None, None, None, 9 0           batch_normalization_25[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_26 (Activation)      (None, None, None, 6 0           batch_normalization_26[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "mixed2 (Concatenate)            (None, None, None, 2 0           activation_20[0][0]              \n",
      "                                                                 activation_22[0][0]              \n",
      "                                                                 activation_25[0][0]              \n",
      "                                                                 activation_26[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_28 (Conv2D)              (None, None, None, 6 18432       mixed2[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_28 (BatchNo (None, None, None, 6 192         conv2d_28[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_28 (Activation)      (None, None, None, 6 0           batch_normalization_28[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_29 (Conv2D)              (None, None, None, 9 55296       activation_28[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_29 (BatchNo (None, None, None, 9 288         conv2d_29[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_29 (Activation)      (None, None, None, 9 0           batch_normalization_29[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_27 (Conv2D)              (None, None, None, 3 995328      mixed2[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_30 (Conv2D)              (None, None, None, 9 82944       activation_29[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_27 (BatchNo (None, None, None, 3 1152        conv2d_27[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_30 (BatchNo (None, None, None, 9 288         conv2d_30[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_27 (Activation)      (None, None, None, 3 0           batch_normalization_27[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_30 (Activation)      (None, None, None, 9 0           batch_normalization_30[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "max_pooling2d_3 (MaxPooling2D)  (None, None, None, 2 0           mixed2[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "mixed3 (Concatenate)            (None, None, None, 7 0           activation_27[0][0]              \n",
      "                                                                 activation_30[0][0]              \n",
      "                                                                 max_pooling2d_3[0][0]            \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_35 (Conv2D)              (None, None, None, 1 98304       mixed3[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_35 (BatchNo (None, None, None, 1 384         conv2d_35[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_35 (Activation)      (None, None, None, 1 0           batch_normalization_35[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_36 (Conv2D)              (None, None, None, 1 114688      activation_35[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_36 (BatchNo (None, None, None, 1 384         conv2d_36[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_36 (Activation)      (None, None, None, 1 0           batch_normalization_36[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_32 (Conv2D)              (None, None, None, 1 98304       mixed3[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_37 (Conv2D)              (None, None, None, 1 114688      activation_36[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_32 (BatchNo (None, None, None, 1 384         conv2d_32[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_37 (BatchNo (None, None, None, 1 384         conv2d_37[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_32 (Activation)      (None, None, None, 1 0           batch_normalization_32[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_37 (Activation)      (None, None, None, 1 0           batch_normalization_37[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_33 (Conv2D)              (None, None, None, 1 114688      activation_32[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_38 (Conv2D)              (None, None, None, 1 114688      activation_37[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_33 (BatchNo (None, None, None, 1 384         conv2d_33[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_38 (BatchNo (None, None, None, 1 384         conv2d_38[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_33 (Activation)      (None, None, None, 1 0           batch_normalization_33[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_38 (Activation)      (None, None, None, 1 0           batch_normalization_38[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "average_pooling2d_4 (AveragePoo (None, None, None, 7 0           mixed3[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_31 (Conv2D)              (None, None, None, 1 147456      mixed3[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_34 (Conv2D)              (None, None, None, 1 172032      activation_33[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_39 (Conv2D)              (None, None, None, 1 172032      activation_38[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_40 (Conv2D)              (None, None, None, 1 147456      average_pooling2d_4[0][0]        \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_31 (BatchNo (None, None, None, 1 576         conv2d_31[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_34 (BatchNo (None, None, None, 1 576         conv2d_34[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_39 (BatchNo (None, None, None, 1 576         conv2d_39[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_40 (BatchNo (None, None, None, 1 576         conv2d_40[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_31 (Activation)      (None, None, None, 1 0           batch_normalization_31[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_34 (Activation)      (None, None, None, 1 0           batch_normalization_34[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_39 (Activation)      (None, None, None, 1 0           batch_normalization_39[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_40 (Activation)      (None, None, None, 1 0           batch_normalization_40[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "mixed4 (Concatenate)            (None, None, None, 7 0           activation_31[0][0]              \n",
      "                                                                 activation_34[0][0]              \n",
      "                                                                 activation_39[0][0]              \n",
      "                                                                 activation_40[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_45 (Conv2D)              (None, None, None, 1 122880      mixed4[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_45 (BatchNo (None, None, None, 1 480         conv2d_45[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_45 (Activation)      (None, None, None, 1 0           batch_normalization_45[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_46 (Conv2D)              (None, None, None, 1 179200      activation_45[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_46 (BatchNo (None, None, None, 1 480         conv2d_46[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_46 (Activation)      (None, None, None, 1 0           batch_normalization_46[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_42 (Conv2D)              (None, None, None, 1 122880      mixed4[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_47 (Conv2D)              (None, None, None, 1 179200      activation_46[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_42 (BatchNo (None, None, None, 1 480         conv2d_42[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_47 (BatchNo (None, None, None, 1 480         conv2d_47[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_42 (Activation)      (None, None, None, 1 0           batch_normalization_42[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_47 (Activation)      (None, None, None, 1 0           batch_normalization_47[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_43 (Conv2D)              (None, None, None, 1 179200      activation_42[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_48 (Conv2D)              (None, None, None, 1 179200      activation_47[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_43 (BatchNo (None, None, None, 1 480         conv2d_43[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_48 (BatchNo (None, None, None, 1 480         conv2d_48[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_43 (Activation)      (None, None, None, 1 0           batch_normalization_43[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_48 (Activation)      (None, None, None, 1 0           batch_normalization_48[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "average_pooling2d_5 (AveragePoo (None, None, None, 7 0           mixed4[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_41 (Conv2D)              (None, None, None, 1 147456      mixed4[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_44 (Conv2D)              (None, None, None, 1 215040      activation_43[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_49 (Conv2D)              (None, None, None, 1 215040      activation_48[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_50 (Conv2D)              (None, None, None, 1 147456      average_pooling2d_5[0][0]        \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_41 (BatchNo (None, None, None, 1 576         conv2d_41[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_44 (BatchNo (None, None, None, 1 576         conv2d_44[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_49 (BatchNo (None, None, None, 1 576         conv2d_49[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_50 (BatchNo (None, None, None, 1 576         conv2d_50[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_41 (Activation)      (None, None, None, 1 0           batch_normalization_41[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_44 (Activation)      (None, None, None, 1 0           batch_normalization_44[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_49 (Activation)      (None, None, None, 1 0           batch_normalization_49[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_50 (Activation)      (None, None, None, 1 0           batch_normalization_50[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "mixed5 (Concatenate)            (None, None, None, 7 0           activation_41[0][0]              \n",
      "                                                                 activation_44[0][0]              \n",
      "                                                                 activation_49[0][0]              \n",
      "                                                                 activation_50[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_55 (Conv2D)              (None, None, None, 1 122880      mixed5[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_55 (BatchNo (None, None, None, 1 480         conv2d_55[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_55 (Activation)      (None, None, None, 1 0           batch_normalization_55[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_56 (Conv2D)              (None, None, None, 1 179200      activation_55[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_56 (BatchNo (None, None, None, 1 480         conv2d_56[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_56 (Activation)      (None, None, None, 1 0           batch_normalization_56[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_52 (Conv2D)              (None, None, None, 1 122880      mixed5[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_57 (Conv2D)              (None, None, None, 1 179200      activation_56[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_52 (BatchNo (None, None, None, 1 480         conv2d_52[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_57 (BatchNo (None, None, None, 1 480         conv2d_57[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_52 (Activation)      (None, None, None, 1 0           batch_normalization_52[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_57 (Activation)      (None, None, None, 1 0           batch_normalization_57[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_53 (Conv2D)              (None, None, None, 1 179200      activation_52[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_58 (Conv2D)              (None, None, None, 1 179200      activation_57[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_53 (BatchNo (None, None, None, 1 480         conv2d_53[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_58 (BatchNo (None, None, None, 1 480         conv2d_58[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_53 (Activation)      (None, None, None, 1 0           batch_normalization_53[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_58 (Activation)      (None, None, None, 1 0           batch_normalization_58[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "average_pooling2d_6 (AveragePoo (None, None, None, 7 0           mixed5[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_51 (Conv2D)              (None, None, None, 1 147456      mixed5[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_54 (Conv2D)              (None, None, None, 1 215040      activation_53[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_59 (Conv2D)              (None, None, None, 1 215040      activation_58[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_60 (Conv2D)              (None, None, None, 1 147456      average_pooling2d_6[0][0]        \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_51 (BatchNo (None, None, None, 1 576         conv2d_51[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_54 (BatchNo (None, None, None, 1 576         conv2d_54[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_59 (BatchNo (None, None, None, 1 576         conv2d_59[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_60 (BatchNo (None, None, None, 1 576         conv2d_60[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_51 (Activation)      (None, None, None, 1 0           batch_normalization_51[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_54 (Activation)      (None, None, None, 1 0           batch_normalization_54[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_59 (Activation)      (None, None, None, 1 0           batch_normalization_59[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_60 (Activation)      (None, None, None, 1 0           batch_normalization_60[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "mixed6 (Concatenate)            (None, None, None, 7 0           activation_51[0][0]              \n",
      "                                                                 activation_54[0][0]              \n",
      "                                                                 activation_59[0][0]              \n",
      "                                                                 activation_60[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_65 (Conv2D)              (None, None, None, 1 147456      mixed6[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_65 (BatchNo (None, None, None, 1 576         conv2d_65[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_65 (Activation)      (None, None, None, 1 0           batch_normalization_65[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_66 (Conv2D)              (None, None, None, 1 258048      activation_65[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_66 (BatchNo (None, None, None, 1 576         conv2d_66[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_66 (Activation)      (None, None, None, 1 0           batch_normalization_66[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_62 (Conv2D)              (None, None, None, 1 147456      mixed6[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_67 (Conv2D)              (None, None, None, 1 258048      activation_66[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_62 (BatchNo (None, None, None, 1 576         conv2d_62[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_67 (BatchNo (None, None, None, 1 576         conv2d_67[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_62 (Activation)      (None, None, None, 1 0           batch_normalization_62[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_67 (Activation)      (None, None, None, 1 0           batch_normalization_67[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_63 (Conv2D)              (None, None, None, 1 258048      activation_62[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_68 (Conv2D)              (None, None, None, 1 258048      activation_67[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_63 (BatchNo (None, None, None, 1 576         conv2d_63[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_68 (BatchNo (None, None, None, 1 576         conv2d_68[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_63 (Activation)      (None, None, None, 1 0           batch_normalization_63[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_68 (Activation)      (None, None, None, 1 0           batch_normalization_68[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "average_pooling2d_7 (AveragePoo (None, None, None, 7 0           mixed6[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_61 (Conv2D)              (None, None, None, 1 147456      mixed6[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_64 (Conv2D)              (None, None, None, 1 258048      activation_63[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_69 (Conv2D)              (None, None, None, 1 258048      activation_68[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_70 (Conv2D)              (None, None, None, 1 147456      average_pooling2d_7[0][0]        \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_61 (BatchNo (None, None, None, 1 576         conv2d_61[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_64 (BatchNo (None, None, None, 1 576         conv2d_64[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_69 (BatchNo (None, None, None, 1 576         conv2d_69[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_70 (BatchNo (None, None, None, 1 576         conv2d_70[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_61 (Activation)      (None, None, None, 1 0           batch_normalization_61[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_64 (Activation)      (None, None, None, 1 0           batch_normalization_64[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_69 (Activation)      (None, None, None, 1 0           batch_normalization_69[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_70 (Activation)      (None, None, None, 1 0           batch_normalization_70[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "mixed7 (Concatenate)            (None, None, None, 7 0           activation_61[0][0]              \n",
      "                                                                 activation_64[0][0]              \n",
      "                                                                 activation_69[0][0]              \n",
      "                                                                 activation_70[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_73 (Conv2D)              (None, None, None, 1 147456      mixed7[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_73 (BatchNo (None, None, None, 1 576         conv2d_73[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_73 (Activation)      (None, None, None, 1 0           batch_normalization_73[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_74 (Conv2D)              (None, None, None, 1 258048      activation_73[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_74 (BatchNo (None, None, None, 1 576         conv2d_74[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_74 (Activation)      (None, None, None, 1 0           batch_normalization_74[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_71 (Conv2D)              (None, None, None, 1 147456      mixed7[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_75 (Conv2D)              (None, None, None, 1 258048      activation_74[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_71 (BatchNo (None, None, None, 1 576         conv2d_71[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_75 (BatchNo (None, None, None, 1 576         conv2d_75[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_71 (Activation)      (None, None, None, 1 0           batch_normalization_71[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_75 (Activation)      (None, None, None, 1 0           batch_normalization_75[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_72 (Conv2D)              (None, None, None, 3 552960      activation_71[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_76 (Conv2D)              (None, None, None, 1 331776      activation_75[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_72 (BatchNo (None, None, None, 3 960         conv2d_72[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_76 (BatchNo (None, None, None, 1 576         conv2d_76[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_72 (Activation)      (None, None, None, 3 0           batch_normalization_72[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_76 (Activation)      (None, None, None, 1 0           batch_normalization_76[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "max_pooling2d_4 (MaxPooling2D)  (None, None, None, 7 0           mixed7[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "mixed8 (Concatenate)            (None, None, None, 1 0           activation_72[0][0]              \n",
      "                                                                 activation_76[0][0]              \n",
      "                                                                 max_pooling2d_4[0][0]            \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_81 (Conv2D)              (None, None, None, 4 573440      mixed8[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_81 (BatchNo (None, None, None, 4 1344        conv2d_81[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_81 (Activation)      (None, None, None, 4 0           batch_normalization_81[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_78 (Conv2D)              (None, None, None, 3 491520      mixed8[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_82 (Conv2D)              (None, None, None, 3 1548288     activation_81[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_78 (BatchNo (None, None, None, 3 1152        conv2d_78[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_82 (BatchNo (None, None, None, 3 1152        conv2d_82[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_78 (Activation)      (None, None, None, 3 0           batch_normalization_78[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_82 (Activation)      (None, None, None, 3 0           batch_normalization_82[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_79 (Conv2D)              (None, None, None, 3 442368      activation_78[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_80 (Conv2D)              (None, None, None, 3 442368      activation_78[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_83 (Conv2D)              (None, None, None, 3 442368      activation_82[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_84 (Conv2D)              (None, None, None, 3 442368      activation_82[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "average_pooling2d_8 (AveragePoo (None, None, None, 1 0           mixed8[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_77 (Conv2D)              (None, None, None, 3 409600      mixed8[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_79 (BatchNo (None, None, None, 3 1152        conv2d_79[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_80 (BatchNo (None, None, None, 3 1152        conv2d_80[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_83 (BatchNo (None, None, None, 3 1152        conv2d_83[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_84 (BatchNo (None, None, None, 3 1152        conv2d_84[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_85 (Conv2D)              (None, None, None, 1 245760      average_pooling2d_8[0][0]        \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_77 (BatchNo (None, None, None, 3 960         conv2d_77[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_79 (Activation)      (None, None, None, 3 0           batch_normalization_79[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_80 (Activation)      (None, None, None, 3 0           batch_normalization_80[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_83 (Activation)      (None, None, None, 3 0           batch_normalization_83[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_84 (Activation)      (None, None, None, 3 0           batch_normalization_84[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_85 (BatchNo (None, None, None, 1 576         conv2d_85[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_77 (Activation)      (None, None, None, 3 0           batch_normalization_77[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "mixed9_0 (Concatenate)          (None, None, None, 7 0           activation_79[0][0]              \n",
      "                                                                 activation_80[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "concatenate_1 (Concatenate)     (None, None, None, 7 0           activation_83[0][0]              \n",
      "                                                                 activation_84[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "activation_85 (Activation)      (None, None, None, 1 0           batch_normalization_85[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "mixed9 (Concatenate)            (None, None, None, 2 0           activation_77[0][0]              \n",
      "                                                                 mixed9_0[0][0]                   \n",
      "                                                                 concatenate_1[0][0]              \n",
      "                                                                 activation_85[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_90 (Conv2D)              (None, None, None, 4 917504      mixed9[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_90 (BatchNo (None, None, None, 4 1344        conv2d_90[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_90 (Activation)      (None, None, None, 4 0           batch_normalization_90[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_87 (Conv2D)              (None, None, None, 3 786432      mixed9[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_91 (Conv2D)              (None, None, None, 3 1548288     activation_90[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_87 (BatchNo (None, None, None, 3 1152        conv2d_87[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_91 (BatchNo (None, None, None, 3 1152        conv2d_91[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_87 (Activation)      (None, None, None, 3 0           batch_normalization_87[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_91 (Activation)      (None, None, None, 3 0           batch_normalization_91[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_88 (Conv2D)              (None, None, None, 3 442368      activation_87[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_89 (Conv2D)              (None, None, None, 3 442368      activation_87[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_92 (Conv2D)              (None, None, None, 3 442368      activation_91[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_93 (Conv2D)              (None, None, None, 3 442368      activation_91[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "average_pooling2d_9 (AveragePoo (None, None, None, 2 0           mixed9[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_86 (Conv2D)              (None, None, None, 3 655360      mixed9[0][0]                     \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_88 (BatchNo (None, None, None, 3 1152        conv2d_88[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_89 (BatchNo (None, None, None, 3 1152        conv2d_89[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_92 (BatchNo (None, None, None, 3 1152        conv2d_92[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_93 (BatchNo (None, None, None, 3 1152        conv2d_93[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "conv2d_94 (Conv2D)              (None, None, None, 1 393216      average_pooling2d_9[0][0]        \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_86 (BatchNo (None, None, None, 3 960         conv2d_86[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_88 (Activation)      (None, None, None, 3 0           batch_normalization_88[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_89 (Activation)      (None, None, None, 3 0           batch_normalization_89[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_92 (Activation)      (None, None, None, 3 0           batch_normalization_92[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "activation_93 (Activation)      (None, None, None, 3 0           batch_normalization_93[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "batch_normalization_94 (BatchNo (None, None, None, 1 576         conv2d_94[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "activation_86 (Activation)      (None, None, None, 3 0           batch_normalization_86[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "mixed9_1 (Concatenate)          (None, None, None, 7 0           activation_88[0][0]              \n",
      "                                                                 activation_89[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "concatenate_2 (Concatenate)     (None, None, None, 7 0           activation_92[0][0]              \n",
      "                                                                 activation_93[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "activation_94 (Activation)      (None, None, None, 1 0           batch_normalization_94[0][0]     \n",
      "__________________________________________________________________________________________________\n",
      "mixed10 (Concatenate)           (None, None, None, 2 0           activation_86[0][0]              \n",
      "                                                                 mixed9_1[0][0]                   \n",
      "                                                                 concatenate_2[0][0]              \n",
      "                                                                 activation_94[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "global_average_pooling2d_1 (Glo (None, 2048)         0           mixed10[0][0]                    \n",
      "__________________________________________________________________________________________________\n",
      "dense_1 (Dense)                 (None, 1024)         2098176     global_average_pooling2d_1[0][0] \n",
      "__________________________________________________________________________________________________\n",
      "dense_2 (Dense)                 (None, 200)          205000      dense_1[0][0]                    \n",
      "==================================================================================================\n",
      "Total params: 24,105,960\n",
      "Trainable params: 2,303,176\n",
      "Non-trainable params: 21,802,784\n",
      "__________________________________________________________________________________________________\n"
     ]
    }
   ],
   "source": [
    "# first: train only the top layers (which were randomly initialized)\n",
    "# i.e. freeze all convolutional InceptionV3 layers\n",
    "for layer in base_model.layers:\n",
    "    layer.trainable = False\n",
    "\n",
    "model.compile(loss='categorical_crossentropy', optimizer='rmsprop', metrics=['accuracy'])\n",
    "\n",
    "model.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/100\n",
      " - 27s - loss: 5.6877 - acc: 0.0098\n",
      "Epoch 2/100\n",
      " - 25s - loss: 5.2656 - acc: 0.0137\n",
      "Epoch 3/100\n",
      " - 26s - loss: 5.1166 - acc: 0.0225\n",
      "Epoch 4/100\n",
      " - 26s - loss: 4.8536 - acc: 0.0420\n",
      "Epoch 5/100\n",
      " - 26s - loss: 4.6319 - acc: 0.0703\n",
      "Epoch 6/100\n",
      " - 26s - loss: 4.2571 - acc: 0.1152\n",
      "Epoch 7/100\n",
      " - 26s - loss: 4.0129 - acc: 0.1406\n",
      "Epoch 8/100\n",
      " - 26s - loss: 3.8202 - acc: 0.1523\n",
      "Epoch 9/100\n",
      " - 26s - loss: 3.6958 - acc: 0.1562\n",
      "Epoch 10/100\n",
      " - 25s - loss: 3.5866 - acc: 0.1702\n",
      "Epoch 11/100\n",
      " - 26s - loss: 3.4458 - acc: 0.1982\n",
      "Epoch 12/100\n",
      " - 26s - loss: 3.2257 - acc: 0.2148\n",
      "Epoch 13/100\n",
      " - 26s - loss: 3.0845 - acc: 0.2402\n",
      "Epoch 14/100\n",
      " - 25s - loss: 3.0548 - acc: 0.2653\n",
      "Epoch 15/100\n",
      " - 26s - loss: 3.0389 - acc: 0.2598\n",
      "Epoch 16/100\n",
      " - 26s - loss: 2.9203 - acc: 0.2832\n",
      "Epoch 17/100\n",
      " - 26s - loss: 2.8910 - acc: 0.2656\n",
      "Epoch 18/100\n",
      " - 26s - loss: 2.7140 - acc: 0.2949\n",
      "Epoch 19/100\n",
      " - 26s - loss: 2.6081 - acc: 0.3418\n",
      "Epoch 20/100\n",
      " - 26s - loss: 2.6706 - acc: 0.3330\n",
      "Epoch 21/100\n",
      " - 26s - loss: 2.6625 - acc: 0.3252\n",
      "Epoch 22/100\n",
      " - 25s - loss: 2.6063 - acc: 0.3320\n",
      "Epoch 23/100\n",
      " - 25s - loss: 2.5528 - acc: 0.3477\n",
      "Epoch 24/100\n",
      " - 25s - loss: 2.4121 - acc: 0.3795\n",
      "Epoch 25/100\n",
      " - 25s - loss: 2.4148 - acc: 0.3828\n",
      "Epoch 26/100\n",
      " - 25s - loss: 2.4513 - acc: 0.3604\n",
      "Epoch 27/100\n",
      " - 25s - loss: 2.4012 - acc: 0.3643\n",
      "Epoch 28/100\n",
      " - 26s - loss: 2.3506 - acc: 0.3975\n",
      "Epoch 29/100\n",
      " - 25s - loss: 2.3188 - acc: 0.4098\n",
      "Epoch 30/100\n",
      " - 26s - loss: 2.1826 - acc: 0.3975\n",
      "Epoch 31/100\n",
      " - 26s - loss: 2.2077 - acc: 0.4033\n",
      "Epoch 32/100\n",
      " - 26s - loss: 2.3368 - acc: 0.4156\n",
      "Epoch 33/100\n",
      " - 26s - loss: 2.3218 - acc: 0.4111\n",
      "Epoch 34/100\n",
      " - 26s - loss: 2.2675 - acc: 0.3975\n",
      "Epoch 35/100\n",
      " - 26s - loss: 2.1536 - acc: 0.4355\n",
      "Epoch 36/100\n",
      " - 26s - loss: 2.0555 - acc: 0.4473\n",
      "Epoch 37/100\n",
      " - 26s - loss: 2.0844 - acc: 0.4561\n",
      "Epoch 38/100\n",
      " - 26s - loss: 1.9837 - acc: 0.4727\n",
      "Epoch 39/100\n",
      " - 26s - loss: 2.2073 - acc: 0.4209\n",
      "Epoch 40/100\n",
      " - 26s - loss: 2.0824 - acc: 0.4570\n",
      "Epoch 41/100\n",
      " - 25s - loss: 2.1241 - acc: 0.4295\n",
      "Epoch 42/100\n",
      " - 26s - loss: 1.9197 - acc: 0.4971\n",
      "Epoch 43/100\n",
      " - 26s - loss: 2.0353 - acc: 0.4717\n",
      "Epoch 44/100\n",
      " - 26s - loss: 1.9665 - acc: 0.4746\n",
      "Epoch 45/100\n",
      " - 26s - loss: 2.1377 - acc: 0.4229\n",
      "Epoch 46/100\n",
      " - 26s - loss: 1.9389 - acc: 0.4834\n",
      "Epoch 47/100\n",
      " - 26s - loss: 1.9568 - acc: 0.4961\n",
      "Epoch 48/100\n",
      " - 26s - loss: 1.8944 - acc: 0.4842\n",
      "Epoch 49/100\n",
      " - 26s - loss: 1.9391 - acc: 0.4941\n",
      "Epoch 50/100\n",
      " - 26s - loss: 1.8493 - acc: 0.4756\n",
      "Epoch 51/100\n",
      " - 26s - loss: 1.8880 - acc: 0.4824\n",
      "Epoch 52/100\n",
      " - 26s - loss: 1.9674 - acc: 0.4756\n",
      "Epoch 53/100\n",
      " - 26s - loss: 1.8496 - acc: 0.5059\n",
      "Epoch 54/100\n",
      " - 26s - loss: 1.8311 - acc: 0.5068\n",
      "Epoch 55/100\n",
      " - 26s - loss: 1.7633 - acc: 0.5244\n",
      "Epoch 56/100\n",
      " - 25s - loss: 1.9060 - acc: 0.4961\n",
      "Epoch 57/100\n",
      " - 26s - loss: 1.7632 - acc: 0.5293\n",
      "Epoch 58/100\n",
      " - 26s - loss: 1.7939 - acc: 0.5176\n",
      "Epoch 59/100\n",
      " - 26s - loss: 1.7710 - acc: 0.5215\n",
      "Epoch 60/100\n",
      " - 25s - loss: 1.6814 - acc: 0.5332\n",
      "Epoch 61/100\n",
      " - 26s - loss: 1.7173 - acc: 0.5254\n",
      "Epoch 62/100\n",
      " - 25s - loss: 1.7579 - acc: 0.5094\n",
      "Epoch 63/100\n",
      " - 26s - loss: 1.6588 - acc: 0.5166\n",
      "Epoch 64/100\n",
      " - 26s - loss: 1.8482 - acc: 0.5234\n",
      "Epoch 65/100\n",
      " - 26s - loss: 1.6791 - acc: 0.5420\n",
      "Epoch 66/100\n",
      " - 25s - loss: 1.6794 - acc: 0.5508\n",
      "Epoch 67/100\n",
      " - 26s - loss: 1.7049 - acc: 0.5186\n",
      "Epoch 68/100\n",
      " - 26s - loss: 1.7028 - acc: 0.5479\n",
      "Epoch 69/100\n",
      " - 26s - loss: 1.6219 - acc: 0.5596\n",
      "Epoch 70/100\n",
      " - 26s - loss: 1.7965 - acc: 0.5420\n",
      "Epoch 71/100\n",
      " - 26s - loss: 1.4968 - acc: 0.5830\n",
      "Epoch 72/100\n",
      " - 26s - loss: 1.6079 - acc: 0.5674\n",
      "Epoch 73/100\n",
      " - 25s - loss: 1.5832 - acc: 0.5491\n",
      "Epoch 74/100\n",
      " - 26s - loss: 1.7109 - acc: 0.5518\n",
      "Epoch 75/100\n",
      " - 26s - loss: 1.6942 - acc: 0.5430\n",
      "Epoch 76/100\n",
      " - 26s - loss: 1.6849 - acc: 0.5547\n",
      "Epoch 77/100\n",
      " - 26s - loss: 1.5219 - acc: 0.5683\n",
      "Epoch 78/100\n",
      " - 26s - loss: 1.6357 - acc: 0.5449\n",
      "Epoch 79/100\n",
      " - 27s - loss: 1.5236 - acc: 0.5947\n",
      "Epoch 80/100\n",
      " - 25s - loss: 1.5834 - acc: 0.5723\n",
      "Epoch 81/100\n",
      " - 27s - loss: 1.6234 - acc: 0.5557\n",
      "Epoch 82/100\n",
      " - 26s - loss: 1.5872 - acc: 0.5264\n",
      "Epoch 83/100\n",
      " - 26s - loss: 1.5392 - acc: 0.5781\n",
      "Epoch 84/100\n",
      " - 26s - loss: 1.5005 - acc: 0.5947\n",
      "Epoch 85/100\n",
      " - 25s - loss: 1.5576 - acc: 0.5673\n",
      "Epoch 86/100\n",
      " - 27s - loss: 1.4386 - acc: 0.6143\n",
      "Epoch 87/100\n",
      " - 26s - loss: 1.4795 - acc: 0.5781\n",
      "Epoch 88/100\n",
      " - 25s - loss: 1.6010 - acc: 0.5518\n",
      "Epoch 89/100\n",
      " - 26s - loss: 1.4460 - acc: 0.5967\n",
      "Epoch 90/100\n",
      " - 26s - loss: 1.5382 - acc: 0.5576\n",
      "Epoch 91/100\n",
      " - 26s - loss: 1.3803 - acc: 0.6133\n",
      "Epoch 92/100\n",
      " - 25s - loss: 1.5539 - acc: 0.5556\n",
      "Epoch 93/100\n",
      " - 26s - loss: 1.5569 - acc: 0.5703\n",
      "Epoch 94/100\n",
      " - 25s - loss: 1.4826 - acc: 0.5791\n",
      "Epoch 95/100\n",
      " - 26s - loss: 1.5378 - acc: 0.5586\n",
      "Epoch 96/100\n",
      " - 26s - loss: 1.5142 - acc: 0.5947\n",
      "Epoch 97/100\n",
      " - 26s - loss: 1.4756 - acc: 0.5762\n",
      "Epoch 98/100\n",
      " - 26s - loss: 1.4465 - acc: 0.6025\n",
      "Epoch 99/100\n",
      " - 26s - loss: 1.5138 - acc: 0.5820\n",
      "Epoch 100/100\n",
      " - 25s - loss: 1.4202 - acc: 0.5928\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<keras.callbacks.History at 0x7fd22067dbe0>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tensorboard = TensorBoard(log_dir='./logs')\n",
    "\n",
    "model.fit_generator(train_generator, steps_per_epoch=32, epochs=100, callbacks=[tensorboard], verbose=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2.3260338047121207, 0.44336327658772534]\n"
     ]
    }
   ],
   "source": [
    "print(model.evaluate_generator(test_generator, steps=5000))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/100\n",
      "32/32 [==============================] - 46s 1s/step - loss: 1.3258 - acc: 0.6212\n",
      "Epoch 2/100\n",
      "32/32 [==============================] - 27s 855ms/step - loss: 1.1749 - acc: 0.6816\n",
      "Epoch 3/100\n",
      "32/32 [==============================] - 27s 855ms/step - loss: 1.1220 - acc: 0.6758\n",
      "Epoch 4/100\n",
      "32/32 [==============================] - 28s 863ms/step - loss: 1.0958 - acc: 0.7109\n",
      "Epoch 5/100\n",
      "32/32 [==============================] - 27s 843ms/step - loss: 1.0043 - acc: 0.7129\n",
      "Epoch 6/100\n",
      "32/32 [==============================] - 27s 855ms/step - loss: 0.9802 - acc: 0.7100\n",
      "Epoch 7/100\n",
      "32/32 [==============================] - 27s 846ms/step - loss: 0.8731 - acc: 0.7432\n",
      "Epoch 8/100\n",
      "32/32 [==============================] - 27s 852ms/step - loss: 0.8452 - acc: 0.7646\n",
      "Epoch 9/100\n",
      "32/32 [==============================] - 27s 859ms/step - loss: 0.8994 - acc: 0.7363\n",
      "Epoch 10/100\n",
      "32/32 [==============================] - 27s 854ms/step - loss: 0.7825 - acc: 0.7588\n",
      "Epoch 11/100\n",
      "32/32 [==============================] - 27s 830ms/step - loss: 0.7927 - acc: 0.7502\n",
      "Epoch 12/100\n",
      "32/32 [==============================] - 27s 851ms/step - loss: 0.7880 - acc: 0.7637\n",
      "Epoch 13/100\n",
      "32/32 [==============================] - 27s 853ms/step - loss: 0.7629 - acc: 0.7656\n",
      "Epoch 14/100\n",
      "32/32 [==============================] - 28s 877ms/step - loss: 0.7313 - acc: 0.7881\n",
      "Epoch 15/100\n",
      "32/32 [==============================] - 27s 833ms/step - loss: 0.7870 - acc: 0.7690\n",
      "Epoch 16/100\n",
      "32/32 [==============================] - 27s 854ms/step - loss: 0.6612 - acc: 0.7969\n",
      "Epoch 17/100\n",
      "32/32 [==============================] - 28s 870ms/step - loss: 0.7177 - acc: 0.7861\n",
      "Epoch 18/100\n",
      "32/32 [==============================] - 28s 872ms/step - loss: 0.6493 - acc: 0.8105\n",
      "Epoch 19/100\n",
      "32/32 [==============================] - 27s 847ms/step - loss: 0.6908 - acc: 0.8164\n",
      "Epoch 20/100\n",
      "32/32 [==============================] - 27s 848ms/step - loss: 0.6758 - acc: 0.8008\n",
      "Epoch 21/100\n",
      "32/32 [==============================] - 28s 873ms/step - loss: 0.6622 - acc: 0.8154\n",
      "Epoch 22/100\n",
      "32/32 [==============================] - 27s 851ms/step - loss: 0.6688 - acc: 0.8057\n",
      "Epoch 23/100\n",
      "32/32 [==============================] - 26s 815ms/step - loss: 0.7104 - acc: 0.8032\n",
      "Epoch 24/100\n",
      "32/32 [==============================] - 27s 854ms/step - loss: 0.6081 - acc: 0.8271\n",
      "Epoch 25/100\n",
      "32/32 [==============================] - 27s 859ms/step - loss: 0.5731 - acc: 0.8271\n",
      "Epoch 26/100\n",
      "32/32 [==============================] - 28s 862ms/step - loss: 0.5968 - acc: 0.8184\n",
      "Epoch 27/100\n",
      "32/32 [==============================] - 27s 853ms/step - loss: 0.5827 - acc: 0.8170\n",
      "Epoch 28/100\n",
      "32/32 [==============================] - 28s 869ms/step - loss: 0.5969 - acc: 0.8203\n",
      "Epoch 29/100\n",
      "32/32 [==============================] - 27s 854ms/step - loss: 0.6201 - acc: 0.8184\n",
      "Epoch 30/100\n",
      "32/32 [==============================] - 27s 854ms/step - loss: 0.5721 - acc: 0.8281\n",
      "Epoch 31/100\n",
      "32/32 [==============================] - 26s 825ms/step - loss: 0.5602 - acc: 0.8276\n",
      "Epoch 32/100\n",
      "32/32 [==============================] - 27s 859ms/step - loss: 0.5226 - acc: 0.8477\n",
      "Epoch 33/100\n",
      "32/32 [==============================] - 28s 866ms/step - loss: 0.5321 - acc: 0.8291\n",
      "Epoch 34/100\n",
      "32/32 [==============================] - 27s 841ms/step - loss: 0.5797 - acc: 0.8330\n",
      "Epoch 35/100\n",
      "32/32 [==============================] - 27s 854ms/step - loss: 0.5447 - acc: 0.8535\n",
      "Epoch 36/100\n",
      "32/32 [==============================] - 29s 896ms/step - loss: 0.5223 - acc: 0.8340\n",
      "Epoch 37/100\n",
      "32/32 [==============================] - 27s 858ms/step - loss: 0.5325 - acc: 0.8311\n",
      "Epoch 38/100\n",
      "32/32 [==============================] - 28s 861ms/step - loss: 0.4934 - acc: 0.8643\n",
      "Epoch 39/100\n",
      "32/32 [==============================] - 27s 842ms/step - loss: 0.5045 - acc: 0.8599\n",
      "Epoch 40/100\n",
      "32/32 [==============================] - 27s 846ms/step - loss: 0.5136 - acc: 0.8584\n",
      "Epoch 41/100\n",
      "32/32 [==============================] - 28s 882ms/step - loss: 0.4896 - acc: 0.8516\n",
      "Epoch 42/100\n",
      "32/32 [==============================] - 28s 864ms/step - loss: 0.4397 - acc: 0.8789\n",
      "Epoch 43/100\n",
      "32/32 [==============================] - 27s 859ms/step - loss: 0.4621 - acc: 0.8633\n",
      "Epoch 44/100\n",
      "32/32 [==============================] - 28s 860ms/step - loss: 0.4429 - acc: 0.8779\n",
      "Epoch 45/100\n",
      "32/32 [==============================] - 28s 879ms/step - loss: 0.4676 - acc: 0.8564\n",
      "Epoch 46/100\n",
      "32/32 [==============================] - 27s 837ms/step - loss: 0.4667 - acc: 0.8685\n",
      "Epoch 47/100\n",
      "32/32 [==============================] - 27s 851ms/step - loss: 0.4443 - acc: 0.8750\n",
      "Epoch 48/100\n",
      "32/32 [==============================] - 27s 846ms/step - loss: 0.4514 - acc: 0.8701\n",
      "Epoch 49/100\n",
      "32/32 [==============================] - 28s 860ms/step - loss: 0.4013 - acc: 0.8789\n",
      "Epoch 50/100\n",
      "32/32 [==============================] - 28s 875ms/step - loss: 0.4547 - acc: 0.8613\n",
      "Epoch 51/100\n",
      "32/32 [==============================] - 27s 843ms/step - loss: 0.4134 - acc: 0.8816\n",
      "Epoch 52/100\n",
      "32/32 [==============================] - 28s 863ms/step - loss: 0.4483 - acc: 0.8701\n",
      "Epoch 53/100\n",
      "32/32 [==============================] - 28s 875ms/step - loss: 0.4610 - acc: 0.8633\n",
      "Epoch 54/100\n",
      "32/32 [==============================] - 27s 851ms/step - loss: 0.4054 - acc: 0.8789\n",
      "Epoch 55/100\n",
      "32/32 [==============================] - 28s 861ms/step - loss: 0.4210 - acc: 0.8926\n",
      "Epoch 56/100\n",
      "32/32 [==============================] - 27s 855ms/step - loss: 0.4697 - acc: 0.8705\n",
      "Epoch 57/100\n",
      "32/32 [==============================] - 28s 862ms/step - loss: 0.4316 - acc: 0.8809\n",
      "Epoch 58/100\n",
      "32/32 [==============================] - 27s 859ms/step - loss: 0.4250 - acc: 0.8887\n",
      "Epoch 59/100\n",
      "32/32 [==============================] - 28s 875ms/step - loss: 0.4422 - acc: 0.8857\n",
      "Epoch 60/100\n",
      "32/32 [==============================] - 27s 830ms/step - loss: 0.3927 - acc: 0.8835\n",
      "Epoch 61/100\n",
      "32/32 [==============================] - 28s 872ms/step - loss: 0.3574 - acc: 0.9102\n",
      "Epoch 62/100\n",
      "32/32 [==============================] - 27s 848ms/step - loss: 0.3856 - acc: 0.8965\n",
      "Epoch 63/100\n",
      "32/32 [==============================] - 28s 861ms/step - loss: 0.4111 - acc: 0.8818\n",
      "Epoch 64/100\n",
      "32/32 [==============================] - 28s 864ms/step - loss: 0.4185 - acc: 0.8857\n",
      "Epoch 65/100\n",
      "32/32 [==============================] - 28s 873ms/step - loss: 0.4053 - acc: 0.8848\n",
      "Epoch 66/100\n",
      "32/32 [==============================] - 28s 868ms/step - loss: 0.3631 - acc: 0.9014\n",
      "Epoch 67/100\n",
      "32/32 [==============================] - 28s 875ms/step - loss: 0.3343 - acc: 0.9043\n",
      "Epoch 68/100\n",
      "32/32 [==============================] - 27s 856ms/step - loss: 0.3304 - acc: 0.9121\n",
      "Epoch 69/100\n",
      "32/32 [==============================] - 28s 865ms/step - loss: 0.3831 - acc: 0.8896\n",
      "Epoch 70/100\n",
      "32/32 [==============================] - 27s 832ms/step - loss: 0.3738 - acc: 0.9033\n",
      "Epoch 71/100\n",
      "32/32 [==============================] - 26s 820ms/step - loss: 0.3913 - acc: 0.8874\n",
      "Epoch 72/100\n",
      "32/32 [==============================] - 28s 861ms/step - loss: 0.3600 - acc: 0.8913\n",
      "Epoch 73/100\n",
      "32/32 [==============================] - 27s 859ms/step - loss: 0.3289 - acc: 0.9102\n",
      "Epoch 74/100\n",
      "32/32 [==============================] - 27s 854ms/step - loss: 0.3741 - acc: 0.9072\n",
      "Epoch 75/100\n",
      "32/32 [==============================] - 27s 853ms/step - loss: 0.3253 - acc: 0.9150\n",
      "Epoch 76/100\n",
      "32/32 [==============================] - 27s 850ms/step - loss: 0.3408 - acc: 0.9053\n",
      "Epoch 77/100\n",
      "32/32 [==============================] - 28s 877ms/step - loss: 0.2782 - acc: 0.9189\n",
      "Epoch 78/100\n",
      "32/32 [==============================] - 27s 858ms/step - loss: 0.3140 - acc: 0.9109\n",
      "Epoch 79/100\n",
      "32/32 [==============================] - 27s 850ms/step - loss: 0.3188 - acc: 0.9268\n",
      "Epoch 80/100\n",
      "32/32 [==============================] - 27s 832ms/step - loss: 0.3392 - acc: 0.9053\n",
      "Epoch 81/100\n",
      "32/32 [==============================] - 27s 839ms/step - loss: 0.3083 - acc: 0.9121\n",
      "Epoch 82/100\n",
      "32/32 [==============================] - 27s 846ms/step - loss: 0.3054 - acc: 0.9121\n",
      "Epoch 83/100\n",
      "32/32 [==============================] - 27s 856ms/step - loss: 0.2792 - acc: 0.9180\n",
      "Epoch 84/100\n",
      "32/32 [==============================] - 27s 858ms/step - loss: 0.3186 - acc: 0.9238\n",
      "Epoch 85/100\n",
      "32/32 [==============================] - 27s 854ms/step - loss: 0.2720 - acc: 0.9277\n",
      "Epoch 86/100\n",
      "32/32 [==============================] - 27s 842ms/step - loss: 0.3192 - acc: 0.9053\n",
      "Epoch 87/100\n",
      "32/32 [==============================] - 27s 835ms/step - loss: 0.3308 - acc: 0.9023\n",
      "Epoch 88/100\n",
      "32/32 [==============================] - 27s 843ms/step - loss: 0.2954 - acc: 0.9219\n",
      "Epoch 89/100\n",
      "32/32 [==============================] - 27s 851ms/step - loss: 0.3198 - acc: 0.9255\n",
      "Epoch 90/100\n",
      "32/32 [==============================] - 27s 859ms/step - loss: 0.3098 - acc: 0.9180\n",
      "Epoch 91/100\n",
      "32/32 [==============================] - 27s 846ms/step - loss: 0.2865 - acc: 0.9268\n",
      "Epoch 92/100\n",
      "32/32 [==============================] - 27s 852ms/step - loss: 0.2902 - acc: 0.9141\n",
      "Epoch 93/100\n",
      "32/32 [==============================] - 27s 832ms/step - loss: 0.2934 - acc: 0.9227\n",
      "Epoch 94/100\n",
      "32/32 [==============================] - 28s 860ms/step - loss: 0.2731 - acc: 0.9307\n",
      "Epoch 95/100\n",
      "32/32 [==============================] - 27s 845ms/step - loss: 0.2777 - acc: 0.9195\n",
      "Epoch 96/100\n",
      "32/32 [==============================] - 27s 848ms/step - loss: 0.2834 - acc: 0.9141\n",
      "Epoch 97/100\n",
      "32/32 [==============================] - 27s 848ms/step - loss: 0.2900 - acc: 0.9219\n",
      "Epoch 98/100\n",
      "32/32 [==============================] - 27s 838ms/step - loss: 0.2482 - acc: 0.9336\n",
      "Epoch 99/100\n",
      "32/32 [==============================] - 27s 846ms/step - loss: 0.2730 - acc: 0.9170\n",
      "Epoch 100/100\n",
      "32/32 [==============================] - 27s 841ms/step - loss: 0.2563 - acc: 0.9316\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<keras.callbacks.History at 0x7fd1f999d828>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# unfreeze all layers for more training\n",
    "for layer in model.layers:\n",
    "    layer.trainable = True\n",
    "\n",
    "# we need to recompile the model for these modifications to take effect\n",
    "# we use SGD with a low learning rate\n",
    "model.compile(optimizer=SGD(lr=0.0001, momentum=0.9), loss='categorical_crossentropy', metrics=['accuracy'])\n",
    "\n",
    "model.fit_generator(train_generator, steps_per_epoch=32, epochs=100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1.4155961280392264, 0.63971983164771662]\n"
     ]
    }
   ],
   "source": [
    "test_generator.reset()\n",
    "print(model.evaluate_generator(test_generator, steps=5000))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "model.save(\"birds-inceptionv3.model\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
